﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace CalemShop
{
    public partial class FrmCheckPoint : Form
    {

        public Customer cs;
        public FrmCheckPoint()
        {
            InitializeComponent();

        }

        private void FrmCheckPoint_Load(object sender, EventArgs e)
        {
            this.txtSearch.Focus();
            txtSearch.AutoCompleteCustomSource = Database.getCustomerDataCollection();
            txtSearch.AutoCompleteMode = AutoCompleteMode.Suggest;
        }

        private void FrmCheckPoint_Activated(object sender, EventArgs e)
        {
            this.txtSearch.Focus();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            if (listCustomer.SelectedItem != null)
            {
                cs = (Customer)listCustomer.SelectedItem;
            }
            this.Close();
        }

        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ArrayList sr = Database.getCustomerListByPhoneOrName(txtSearch.Text);
                if (sr != null)
                {
                    listCustomer.DataSource = sr;
                    listCustomer.Focus();
                }

            }
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
